/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package torrent;

import java.awt.List;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author THIEUQUANG
 */
public class Table {

    public static DefaultTableModel TableModel(ArrayList<ArrayList<String>> ds) {
        DefaultTableModel dtm = new DefaultTableModel();

        //Tao cot
        dtm.addColumn("Tên file");
        dtm.addColumn("Số lượng chunk");
        dtm.addColumn("Tình trạng");

        //Dữ liệu
        dtm.setRowCount(ds.size());
        for (int i = 0; i < ds.size(); i++) {
            ArrayList<String> list = new ArrayList<String>();
            list = ds.get(i);
            dtm.setValueAt(list.get(0), i, 0);
            dtm.setValueAt(list.get(1), i, 1);
            dtm.setValueAt(list.get(2), i, 2);
        }

        return dtm;
    }
}
